/**
 * Email validation from stackoverflow
 * http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
 * @param email
 * @returns {Boolean}
 */
function validateEmail(email) {
	var retval = false;
	if (email.length > 0) {
		var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
		retval = re.test(email);
	} else {
		retval = true;
	}
    
    return retval;
} 

/**
 * Phone number validation method
 * @param phone
 * @returns {Boolean}
 */
function validatePhone(phone) {
	var retval = false;
	//check only not null length input
	if (phone.length > 0) {
		var re = /^[0-9 \+]*$/;
		retval = re.test(phone);
	} else {
		retval = true;
	}
	
	return retval;
}

/**
 * JS to send form and check for phone nr and email
 */
function sendForm() {
	if (validateEmail(jQuery('#email').val()) && 
		validatePhone(jQuery('#phone').val()) &&
		jQuery('#comment').val().length > 0) {
		jQuery('#feedbackForm').submit();
	} else {
		alert('Problem with comment, email or phone');
	}
	
}